package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.UserInfoBuyerTicketMiddle;
import cn.icanci.ladybird.dao.UserInfoBuyerTicketMiddleDao;
import cn.icanci.ladybird.service.UserInfoBuyerTicketMiddleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserInfoBuyerTicketMiddle)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:45:18
 */
@Service("userInfoBuyerTicketMiddleService")
public class UserInfoBuyerTicketMiddleServiceImpl implements UserInfoBuyerTicketMiddleService {
    @Resource
    private UserInfoBuyerTicketMiddleDao userInfoBuyerTicketMiddleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userInfoBuyerTicketMiddleId 主键
     * @return 实例对象
     */
    @Override
    public UserInfoBuyerTicketMiddle queryById(Long userInfoBuyerTicketMiddleId) {
        return this.userInfoBuyerTicketMiddleDao.queryById(userInfoBuyerTicketMiddleId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserInfoBuyerTicketMiddle> queryAllByLimit(int offset, int limit) {
        return this.userInfoBuyerTicketMiddleDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userInfoBuyerTicketMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public UserInfoBuyerTicketMiddle insert(UserInfoBuyerTicketMiddle userInfoBuyerTicketMiddle) {
        this.userInfoBuyerTicketMiddleDao.insert(userInfoBuyerTicketMiddle);
        return userInfoBuyerTicketMiddle;
    }

    /**
     * 修改数据
     *
     * @param userInfoBuyerTicketMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public UserInfoBuyerTicketMiddle update(UserInfoBuyerTicketMiddle userInfoBuyerTicketMiddle) {
        this.userInfoBuyerTicketMiddleDao.update(userInfoBuyerTicketMiddle);
        return this.queryById(userInfoBuyerTicketMiddle.getUserInfoBuyerTicketMiddleId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userInfoBuyerTicketMiddleId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long userInfoBuyerTicketMiddleId) {
        return this.userInfoBuyerTicketMiddleDao.deleteById(userInfoBuyerTicketMiddleId) > 0;
    }

    @Override
    public List<UserInfoBuyerTicketMiddle> queryByUserInfoId(Long userInfoId) {
        return this.userInfoBuyerTicketMiddleDao.queryByUserInfoId(userInfoId);
    }

    @Override
    public UserInfoBuyerTicketMiddle queryByTicketId(Long buyTicketId) {
        return  this.userInfoBuyerTicketMiddleDao.queryByTicketId(buyTicketId);
    }

    @Override
    public void deleteByTicketId(Long buyTicketId) {
        this.userInfoBuyerTicketMiddleDao.deleteByTicketId(buyTicketId);
    }
}